package org.jeecg.modules.flow.service;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.flow.entity.FlowAudit;
import org.jeecg.modules.flow.query.*;
import org.jeecg.modules.flow.vo.*;

import java.util.List;
import java.util.Map;
import java.util.Set;


/**
 * 流程基础service层
 *
 * @Author: zzq
 */
public interface IFlowBaseService {

    /**
     * 启动流程实例
     *
     * @param query 封装类
     * @return
     */
    Result<String> startInstance(StartInstanceQuery query);

    /**
     * 查询流程实例
     *
     * @param processId 流程实例Id
     * @return
     */
    ProInstanceVo searchInstanceById(String processId);


    /**
     * 删除流程实例
     *
     * @param instanceId
     * @param reason     删除原因
     * @return
     */
    boolean delInstanceById(String instanceId, String reason);

    /**
     * 查询个人任务列表
     *
     * @param assignee
     * @return
     */
    List<TaskVo> findTaskByAssignee(String assignee);


    /**
     * 查询流程实例变量
     *
     * @param taskId 任务ID
     * @return
     */
    Map<String, Object> getVariablesByTaskId(String taskId, List<String> variableNames, boolean isHistory);


    /**
     * @param query
     * @return
     */
    Result<Boolean> submitTask(SubmitTaskQuery query);

    /**
     * 根据businessKey获取流程实例信息
     *
     * @param businessKey
     * @return
     */
    ProInstanceVo getInstanceByBusinessKey(String businessKey);

    /**
     * 根据BusinessKey获取流程实实例下当前活动的任务
     *
     * @param businessKey
     * @return
     */
    TaskVo getActiveTaskByBusinessKey(String businessKey);

    /**
     * 根据流程实例Ids查询流程实例列表
     *
     * @param instanceIds
     * @return
     */
    List<ProInstanceVo> searchInstanceByIds(Set<String> instanceIds);

    /**
     * 查询审批意见
     *
     * @param instanceId
     * @param taskId
     */
    List<FlowAudit> getComment(String instanceId, String taskId);

    /**
     * 根据流程名称模糊查询流程
     *
     * @param instanceName
     * @return
     */
    List<Map<String, Object>> likeInstanceByName(String instanceName);


}
